package world.hezi.handlers;

import net.mamoe.mirai.event.EventHandler;
import net.mamoe.mirai.event.ListeningStatus;
import net.mamoe.mirai.event.SimpleListenerHost;
import net.mamoe.mirai.event.events.MessageEvent;
import org.jetbrains.annotations.NotNull;
import world.hezi.http.SendChatGPT;

public class ChatHandlers extends SimpleListenerHost {
    @EventHandler
    public ListeningStatus onApply(@NotNull MessageEvent event){
        String message = event.getMessage().contentToString();
        if (message.indexOf("/chat") != 0){
            return ListeningStatus.LISTENING;
        }
        message = message.replaceAll("/chat","").trim();
        try {
            event.getSubject().sendMessage("让我想想...");
            SendChatGPT.execute(event,message);
        }catch (Exception e){
            event.getSubject().sendMessage(e.getMessage());
        }
        return ListeningStatus.LISTENING;
    }

    public static void main(String[] args) {
//        System.out.println("\\n,啊水水\\nasfdafasd".replaceAll("[\]", "\n"));
    }
}
